﻿
-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_PageGetBySearchAndReplaceId'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_PageGetBySearchAndReplaceId') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_PageGetBySearchAndReplaceId]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_PageGetBySearchAndReplaceId]
	@SearchAndReplaceId uniqueidentifier
AS
	/****************************************************************************/
	/* Summary: Selects all records from table 'sar_Page' where the value of    */
	/* column 'SearchAndReplaceId' matches the value of parameter               */
	/* '@SearchAndReplaceId'.                                                   */
	/****************************************************************************/

	SET NOCOUNT ON;

	SELECT [Id],
	[SearchAndReplaceId],
	[PageId],
	[WorkId],
	[PreviousWorkId],
	[LanguageBranch],
	[SortIndex]
	FROM [sar_Page]
	WHERE [SearchAndReplaceId] = @SearchAndReplaceId
	ORDER BY [SortIndex] ASC

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_PageInsert'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_PageInsert') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_PageInsert]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_PageInsert]
	@Id uniqueidentifier,
	@SearchAndReplaceId uniqueidentifier,
	@PageId int,
	@WorkId int,
	@PreviousWorkId int,
	@LanguageBranch nvarchar(50),
	@SortIndex int
AS
	/****************************************************************************/
	/* Summary: Inserts a new record into table 'sar_Page'.                     */
	/****************************************************************************/

	SET NOCOUNT ON;

	INSERT INTO [sar_Page]
	([Id],
	[SearchAndReplaceId],
	[PageId],
	[WorkId],
	[PreviousWorkId],
	[LanguageBranch],
	[SortIndex])
	VALUES
	(@Id,
	@SearchAndReplaceId,
	@PageId,
	@WorkId,
	@PreviousWorkId,
	@LanguageBranch,
	@SortIndex)

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_PageUpdate'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_PageUpdate') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_PageUpdate]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_PageUpdate]
	@Id uniqueidentifier,
	@SearchAndReplaceId uniqueidentifier,
	@PageId int,
	@WorkId int,
	@PreviousWorkId int,
	@LanguageBranch nvarchar(50),
	@SortIndex int
AS
	/****************************************************************************/
	/* Summary: Updates an existing record in table 'sar_Page'.                 */
	/****************************************************************************/

	SET NOCOUNT ON;

	UPDATE [sar_Page]
	SET [SearchAndReplaceId] = @SearchAndReplaceId,
	[PageId] = @PageId,
	[WorkId] = @WorkId,
	[PreviousWorkId] = @PreviousWorkId,
	[LanguageBranch] = @LanguageBranch,
	[SortIndex] = @SortIndex
	WHERE [Id] = @Id

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_PageDelete'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_PageDelete') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_PageDelete]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_PageDelete]
	@Id uniqueidentifier
AS
	/****************************************************************************/
	/* Summary: Deletes a record from table 'sar_Page'.                         */
	/****************************************************************************/

	SET NOCOUNT ON;

	DELETE FROM [sar_Page]
	WHERE [Id] = @Id

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_DynamicPropertyGetBySearchAndReplaceId'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_DynamicPropertyGetBySearchAndReplaceId') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_DynamicPropertyGetBySearchAndReplaceId]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_DynamicPropertyGetBySearchAndReplaceId]
	@SearchAndReplaceId uniqueidentifier
AS
	/***************************************************************************************/
	/* Summary: Selects all records from table 'sar_DynamicProperty' where the value of    */
	/* column 'SearchAndReplaceId' matches the value of parameter '@SearchAndReplaceId'.   */
	/***************************************************************************************/

	SET NOCOUNT ON;

	SELECT [Id],
	[SearchAndReplaceId],
	[PageId],
	[WorkId],
	[LanguageBranch],
	[PropertyName],
	[SortIndex]
	FROM [sar_DynamicProperty]
	WHERE [SearchAndReplaceId] = @SearchAndReplaceId
	ORDER BY [SortIndex] ASC

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_DynamicPropertyInsert'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_DynamicPropertyInsert') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_DynamicPropertyInsert]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_DynamicPropertyInsert]
	@Id uniqueidentifier,
	@SearchAndReplaceId uniqueidentifier,
	@PageId int,
	@WorkId int,
	@LanguageBranch nvarchar(50),
	@PropertyName nvarchar(100),
	@SortIndex int
AS
	/****************************************************************************/
	/* Summary: Inserts a new record into table 'sar_DynamicProperty'.          */
	/****************************************************************************/

	SET NOCOUNT ON;

	INSERT INTO [sar_DynamicProperty]
	([Id],
	[SearchAndReplaceId],
	[PageId],
	[WorkId],
	[LanguageBranch],
	[PropertyName],
	[SortIndex])
	VALUES
	(@Id,
	@SearchAndReplaceId,
	@PageId,
	@WorkId,
	@LanguageBranch,
	@PropertyName,
	@SortIndex)

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_DynamicPropertyUpdate'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_DynamicPropertyUpdate') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_DynamicPropertyUpdate]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_DynamicPropertyUpdate]
	@Id uniqueidentifier,
	@SearchAndReplaceId uniqueidentifier,
	@PageId int,
	@WorkId int,
	@LanguageBranch nvarchar(50),
	@PropertyName nvarchar(100),
	@SortIndex int
AS
	/****************************************************************************/
	/* Summary: Updates an existing record in table 'sar_DynamicProperty'.      */
	/****************************************************************************/

	SET NOCOUNT ON;

	UPDATE [sar_DynamicProperty]
	SET [SearchAndReplaceId] = @SearchAndReplaceId,
	[PageId] = @PageId,
	[WorkId] = @WorkId,
	[LanguageBranch] = @LanguageBranch,
	[PropertyName] = @PropertyName,
	[SortIndex] = @SortIndex
	WHERE [Id] = @Id

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_DynamicPropertyDelete'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_DynamicPropertyDelete') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_DynamicPropertyDelete]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_DynamicPropertyDelete]
	@Id uniqueidentifier
AS
	/****************************************************************************/
	/* Summary: Deletes a record from table 'sar_DynamicProperty'.              */
	/****************************************************************************/

	SET NOCOUNT ON;

	DELETE FROM [sar_DynamicProperty]
	WHERE [Id] = @Id

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_ErrorGetBySearchAndReplaceId'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_ErrorGetBySearchAndReplaceId') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_ErrorGetBySearchAndReplaceId]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_ErrorGetBySearchAndReplaceId]
	@SearchAndReplaceId uniqueidentifier
AS
	/***************************************************************************************/
	/* Summary: Selects all records from table 'sar_Error' where the value of    */
	/* column 'SearchAndReplaceId' matches the value of parameter '@SearchAndReplaceId'.   */
	/***************************************************************************************/

	SET NOCOUNT ON;

	SELECT [Id],
	[SearchAndReplaceId],
	[PageId],
	[WorkId],
	[LanguageBranch],
	[PropertyName],
	[ErrorMessage],
	[PageProperty],
	[SortIndex]
	FROM [sar_Error]
	WHERE [SearchAndReplaceId] = @SearchAndReplaceId
	ORDER BY [SortIndex] ASC

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_ErrorInsert'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_ErrorInsert') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_ErrorInsert]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_ErrorInsert]
	@Id uniqueidentifier,
	@SearchAndReplaceId uniqueidentifier,
	@PageId int,
	@WorkId int,
	@LanguageBranch nvarchar(50),
	@PropertyName nvarchar(100),
	@ErrorMessage nvarchar(1024),
	@PageProperty bit,
	@SortIndex int
AS
	/****************************************************************************/
	/* Summary: Inserts a new record into table 'sar_Error'.          */
	/****************************************************************************/

	SET NOCOUNT ON;

	INSERT INTO [sar_Error]
	([Id],
	[SearchAndReplaceId],
	[PageId],
	[WorkId],
	[LanguageBranch],
	[PropertyName],
	[ErrorMessage],
	[PageProperty],
	[SortIndex])
	VALUES
	(@Id,
	@SearchAndReplaceId,
	@PageId,
	@WorkId,
	@LanguageBranch,
	@PropertyName,
	@ErrorMessage,
	@PageProperty,
	@SortIndex)

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_ErrorUpdate'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_ErrorUpdate') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_ErrorUpdate]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_ErrorUpdate]
	@Id uniqueidentifier,
	@SearchAndReplaceId uniqueidentifier,
	@PageId int,
	@WorkId int,
	@LanguageBranch nvarchar(50),
	@PropertyName nvarchar(100),
	@ErrorMessage nvarchar(1024),
	@PageProperty bit,
	@SortIndex int
AS
	/****************************************************************************/
	/* Summary: Updates an existing record in table 'sar_Error'.      */
	/****************************************************************************/

	SET NOCOUNT ON;

	UPDATE [sar_Error]
	SET [SearchAndReplaceId] = @SearchAndReplaceId,
	[PageId] = @PageId,
	[WorkId] = @WorkId,
	[LanguageBranch] = @LanguageBranch,
	[PropertyName] = @PropertyName,
	[ErrorMessage] = @ErrorMessage,
	[PageProperty] = @PageProperty,
	[SortIndex] = @SortIndex
	WHERE [Id] = @Id

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_ErrorDelete'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_ErrorDelete') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_ErrorDelete]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_ErrorDelete]
	@Id uniqueidentifier
AS
	/****************************************************************************/
	/* Summary: Deletes a record from table 'sar_Error'.              */
	/****************************************************************************/

	SET NOCOUNT ON;

	DELETE FROM [sar_Error]
	WHERE [Id] = @Id

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO



-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_SearchAndReplaceGetAll'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_SearchAndReplaceGetAll') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_SearchAndReplaceGetAll]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_SearchAndReplaceGetAll]
AS
	/****************************************************************************/
	/* Summary: Selects all records from table 'sar_SearchAndReplace'.          */
	/****************************************************************************/

	SET NOCOUNT ON;

	SELECT [Id],
	[StartPage],
	[Created],
	[CreatedBy],
	[Find],
	[Replace],
	[MatchCase],
	[UpdateDynamicProperties],
	[SearchWithinWords],
	[StartPageOnly],
	[LanguageBranch],
	[Completed]
	FROM [sar_SearchAndReplace]
	ORDER BY [Created] DESC

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_SearchAndReplaceGetById'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_SearchAndReplaceGetById') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_SearchAndReplaceGetById]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_SearchAndReplaceGetById]
	@Id uniqueidentifier
AS
	/****************************************************************************/
	/* Summary: Selects all records from table 'sar_SearchAndReplace' where     */
	/* the value of column 'Id' matches the value of parameter '@Id'.           */
	/****************************************************************************/

	SET NOCOUNT ON;

	SELECT [Id],
	[StartPage],
	[Created],
	[CreatedBy],
	[Find],
	[Replace],
	[MatchCase],
	[UpdateDynamicProperties],
	[SearchWithinWords],
	[StartPageOnly],
	[LanguageBranch],
	[Completed]
	FROM [sar_SearchAndReplace]
	WHERE [Id] = @Id

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_SearchAndReplaceInsert'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_SearchAndReplaceInsert') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_SearchAndReplaceInsert]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_SearchAndReplaceInsert]
	@Id uniqueidentifier,
	@StartPage nvarchar (50),
	@Created datetime,
	@CreatedBy nvarchar (100),
	@Find nvarchar (1024),
	@Replace nvarchar (1024),
	@MatchCase bit,
	@UpdateDynamicProperties bit,
	@SearchWithinWords bit,
	@StartPageOnly bit,
	@LanguageBranch nvarchar (50),
	@Completed bit
AS
	/****************************************************************************/
	/* Summary: Inserts a new record into table 'sar_SearchAndReplace'.         */
	/****************************************************************************/

	SET NOCOUNT ON;

	INSERT INTO [sar_SearchAndReplace]
	([Id],
	[StartPage],
	[Created],
	[CreatedBy],
	[Find],
	[Replace],
	[MatchCase],
	[UpdateDynamicProperties],
	[SearchWithinWords],
	[StartPageOnly],
	[LanguageBranch],
	[Completed])
	VALUES
	(@Id,
	@StartPage,
	@Created,
	@CreatedBy,
	@Find,
	@Replace,
	@MatchCase,
	@UpdateDynamicProperties,
	@SearchWithinWords,
	@StartPageOnly,
	@LanguageBranch,
	@Completed)

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_SearchAndReplaceUpdate'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_SearchAndReplaceUpdate') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_SearchAndReplaceUpdate]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_SearchAndReplaceUpdate]
	@Id uniqueidentifier,
	@StartPage nvarchar (50),
	@Created datetime,
	@CreatedBy nvarchar (100),
	@Find nvarchar (1024),
	@Replace nvarchar (1024),
	@MatchCase bit,
	@UpdateDynamicProperties bit,
	@SearchWithinWords bit,
	@StartPageOnly bit,
	@LanguageBranch nvarchar (50),
	@Completed bit
AS
	/****************************************************************************/
	/* Summary: Updates an existing record in table 'sar_SearchAndReplace'.     */
	/****************************************************************************/

	SET NOCOUNT ON;

	UPDATE [sar_SearchAndReplace]
	SET [StartPage] = @StartPage,
	[Created] = @Created,
	[CreatedBy] = @CreatedBy,
	[Find] = @Find,
	[Replace] = @Replace,
	[MatchCase] = @MatchCase,
	[UpdateDynamicProperties] = @UpdateDynamicProperties,
	[SearchWithinWords] = @SearchWithinWords,
	[StartPageOnly] = @StartPageOnly,
	[LanguageBranch] = @LanguageBranch,
	[Completed]= @Completed
	WHERE [Id] = @Id

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

-- SCRIPT FOR CREATING PROCEDURE 'usp_sar_SearchAndReplaceDelete'

-- Drop the procedure if it already exists
IF exists (select * from dbo.sysobjects where id = object_id(N'usp_sar_SearchAndReplaceDelete') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
    DROP PROCEDURE [usp_sar_SearchAndReplaceDelete]
END

GO


CREATE PROCEDURE [dbo].[usp_sar_SearchAndReplaceDelete]
	@Id uniqueidentifier
AS
	/****************************************************************************/
	/* Summary: Deletes a record from table 'sar_SearchAndReplace'.             */
	/****************************************************************************/

	SET NOCOUNT ON;

	DELETE FROM [sar_SearchAndReplace]
	WHERE [Id] = @Id

	IF @@ROWCOUNT = 1
		RETURN 0
	ELSE
		RETURN -1

GO

